<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
           "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Coverage Report</title>
<link title="Style" type="text/css" rel="stylesheet" href="css/main.css"/>
<script type="text/javascript" src="js/popup.js"></script>
</head>
<body>
<h5>Coverage Report - ch.lambdaj.util.IntrospectionUtil</h5>
<div class="separator">&nbsp;</div>
<table class="report">
<thead><tr>  <td class="heading">Classes in this File</td>  <td class="heading"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">Line Coverage</a></td>  <td class="heading"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">Branch Coverage</a></td>  <td class="heading"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">Complexity</a></td></tr></thead>
  <tr><td><a href="ch.lambdaj.util.IntrospectionUtil.html">IntrospectionUtil</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">93%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:93px"><span class="text">46/49</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">78%</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:78px"><span class="text">39/50</span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.875;</span>3,875</td></tr>

</table>
<div class="separator">&nbsp;</div>
<table cellspacing="0" cellpadding="0" class="src">
<tr>  <td class="numLine">&nbsp;1</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">// Modified or written by Lambdascale SRL for inclusion with lambdaj.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;2</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">// Copyright (c) 2009-2010 Mario Fusco.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;3</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">// Licensed under the Apache License, Version 2.0 (the "License")</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;4</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;5</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">package</span> ch.lambdaj.util;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;6</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;7</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.lang.reflect.*;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;8</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.*;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;9</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;10</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;11</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * This class consists exclusively of static methods that offer some introspection facilities.</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;12</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> * @author Mario Fusco</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;13</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment"> */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;14</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="keyword">public</span> <span class="keyword">final</span> <span class="keyword">class</span> IntrospectionUtil {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;15</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;16</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;        <span class="keyword">private</span> IntrospectionUtil() {}</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;17</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;18</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;19</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Returns the bean compliant name of the property accessed by the given method</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;20</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @param invokedMethod The method to be introspected</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;21</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @return The bean compliant name of the property accessed by the given method</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;22</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;23</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">static</span> String getPropertyName(Method invokedMethod) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;24</td>  <td class="nbHitsCovered">&nbsp;11</td>  <td class="src"><pre class="src">&nbsp;                String methodName = invokedMethod.getName();</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;25</td>  <td class="nbHitsUncovered"><a title="Line 25: Conditional coverage 50% (3/6) [each condition: 50%, 0%, 100%].">&nbsp;11</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 25: Conditional coverage 50% (3/6) [each condition: 50%, 0%, 100%].">                <span class="keyword">if</span> ((methodName.startsWith(<span class="string">"get"</span>) || methodName.startsWith(<span class="string">"set"</span>)) &amp;&amp; methodName.length() &gt; 3) methodName = methodName.substring(3);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;26</td>  <td class="nbHitsUncovered"><a title="Line 26: Conditional coverage 25% (1/4) [each condition: 50%, 0%].">&nbsp;1</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 26: Conditional coverage 25% (1/4) [each condition: 50%, 0%].">                <span class="keyword">else</span> <span class="keyword">if</span> (methodName.startsWith(<span class="string">"is"</span>) &amp;&amp; methodName.length() &gt; 2) methodName = methodName.substring(2);</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;27</td>  <td class="nbHitsCovered">&nbsp;11</td>  <td class="src"><pre class="src">&nbsp;                <span class="keyword">return</span> methodName.substring(0, 1).toLowerCase(Locale.getDefault()) + methodName.substring(1);</pre></td></tr>
<tr>  <td class="numLine">&nbsp;28</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;29</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;30</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;31</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Return the value of named property on the given bean</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;32</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @param bean The bean to be introspected</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;33</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @param propertyName The name of the property to be introspected</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;34</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @return The value of named property on the given bean</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;35</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;36</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">public</span> <span class="keyword">static</span> Object getPropertyValue(Object bean, String propertyName) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;37</td>  <td class="nbHitsCovered"><a title="Line 37: Conditional coverage 100% (2/2).">&nbsp;125</a></td>  <td class="src"><pre class="src">&nbsp;<a title="Line 37: Conditional coverage 100% (2/2).">                <span class="keyword">if</span> (bean == <span class="keyword">null</span>) <span class="keyword">return</span> <span class="keyword">null</span>;</a></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;38</td>  <td class="nbHitsCovered">&nbsp;120</td>  <td class="src"><pre class="src">&nbsp;                <span class="keyword">int</span> dotPos = propertyName.indexOf(<span class="string">'.'</span>);</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;39</td>  <td class="nbHitsCovered"><a title="Line 39: Conditional coverage 100% (2/2).">&nbsp;120</a></td>  <td class="src"><pre class="src">&nbsp;<a title="Line 39: Conditional coverage 100% (2/2).">                <span class="keyword">if</span> (dotPos &gt; 0) <span class="keyword">return</span> getPropertyValue(getPropertyValue(bean, propertyName.substring(0, dotPos)), propertyName.substring(dotPos + 1));</a></pre></td></tr>
<tr>  <td class="numLine">&nbsp;40</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;41</td>  <td class="nbHitsCovered">&nbsp;105</td>  <td class="src"><pre class="src">&nbsp;                String accessorName = propertyName.substring(0, 1).toUpperCase(Locale.getDefault()) + propertyName.substring(1);</pre></td></tr>
<tr>  <td class="numLine">&nbsp;42</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;43</td>  <td class="nbHitsCovered">&nbsp;105</td>  <td class="src"><pre class="src">&nbsp;                        <span class="keyword">return</span> bean.getClass().getMethod(<span class="string">"get"</span> + accessorName).invoke(bean, (Object[]) <span class="keyword">null</span>);</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;44</td>  <td class="nbHitsCovered">&nbsp;25</td>  <td class="src"><pre class="src">&nbsp;                } <span class="keyword">catch</span> (Exception e) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;45</td>  <td class="nbHitsCovered">&nbsp;25</td>  <td class="src"><pre class="src">&nbsp;                        <span class="keyword">return</span> getBooleanPropertyValue(bean, propertyName, accessorName);</pre></td></tr>
<tr>  <td class="numLine">&nbsp;46</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;47</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;48</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        </pre></td></tr>
<tr>  <td class="numLine">&nbsp;49</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">private</span> <span class="keyword">static</span> Object getBooleanPropertyValue(Object bean, String propertyName, String accessorName) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;50</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;51</td>  <td class="nbHitsCovered">&nbsp;25</td>  <td class="src"><pre class="src">&nbsp;                        <span class="keyword">return</span> bean.getClass().getMethod(<span class="string">"is"</span> + accessorName).invoke(bean, (Object[]) <span class="keyword">null</span>);</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;52</td>  <td class="nbHitsCovered">&nbsp;25</td>  <td class="src"><pre class="src">&nbsp;                } <span class="keyword">catch</span> (Exception e) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;53</td>  <td class="nbHitsCovered">&nbsp;25</td>  <td class="src"><pre class="src">&nbsp;                        <span class="keyword">return</span> getPlainPropertyValue(bean, propertyName);</pre></td></tr>
<tr>  <td class="numLine">&nbsp;54</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;55</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;56</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        </pre></td></tr>
<tr>  <td class="numLine">&nbsp;57</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">private</span> <span class="keyword">static</span> Object getPlainPropertyValue(Object bean, String propertyName) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;58</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;59</td>  <td class="nbHitsCovered">&nbsp;25</td>  <td class="src"><pre class="src">&nbsp;                        <span class="keyword">return</span> bean.getClass().getMethod(propertyName).invoke(bean, (Object[]) <span class="keyword">null</span>);</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;60</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                } <span class="keyword">catch</span> (Exception e) {</span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;61</td>  <td class="nbHitsUncovered">&nbsp;0</td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;                        <span class="keyword">throw</span> <span class="keyword">new</span> IntrospectionException(e);</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;62</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;63</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;64</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;65</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;66</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Finds the consructor of the given class that matches the given arguments</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;67</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @param clazz The class for which a constructor should be found</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;68</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @param args The arguments that have to be assignable to the parameters of the constructor to be found</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;69</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @return The consructor of the given class that matches the given arguments</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;70</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;71</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">public</span> <span class="keyword">static</span> &lt;T&gt; Constructor&lt;T&gt; findConstructor(Class&lt;T&gt; clazz, Object... args) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;72</td>  <td class="nbHitsCovered">&nbsp;4</td>  <td class="src"><pre class="src">&nbsp;        <span class="keyword">return</span> findConstructor(clazz, objectsToClasses(args));</pre></td></tr>
<tr>  <td class="numLine">&nbsp;73</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;74</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;75</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;76</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Finds the consructor of the given class having arguments of the given types</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;77</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @param clazz The class for which a constructor should be found</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;78</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @param parameterTypes The types of the parameters of the constructor to be found</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;79</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @return The consructor of the given class having arguments of the given types</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;80</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;81</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">public</span> <span class="keyword">static</span> &lt;T&gt; Constructor&lt;T&gt; findConstructor(Class&lt;T&gt; clazz, Class&lt;?&gt;... parameterTypes) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;82</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;83</td>  <td class="nbHitsCovered">&nbsp;4</td>  <td class="src"><pre class="src">&nbsp;            <span class="keyword">return</span> clazz.getConstructor(parameterTypes);</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;84</td>  <td class="nbHitsCovered">&nbsp;4</td>  <td class="src"><pre class="src">&nbsp;        } <span class="keyword">catch</span> (NoSuchMethodException e) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;85</td>  <td class="nbHitsCovered">&nbsp;4</td>  <td class="src"><pre class="src">&nbsp;            Constructor&lt;T&gt; constructor = discoverConstructor(clazz, parameterTypes);</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;86</td>  <td class="nbHitsCovered"><a title="Line 86: Conditional coverage 100% (2/2).">&nbsp;4</a></td>  <td class="src"><pre class="src">&nbsp;<a title="Line 86: Conditional coverage 100% (2/2).">            <span class="keyword">if</span> (constructor == <span class="keyword">null</span>) <span class="keyword">throw</span> <span class="keyword">new</span> IntrospectionException(e);</a></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;87</td>  <td class="nbHitsCovered">&nbsp;3</td>  <td class="src"><pre class="src">&nbsp;            <span class="keyword">return</span> constructor;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;88</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;89</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;90</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;91</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">static</span> &lt;T&gt; Constructor&lt;T&gt; discoverConstructor(Class&lt;?&gt; clazz, Class&lt;?&gt;... parameterTypes) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;92</td>  <td class="nbHitsCovered"><a title="Line 92: Conditional coverage 100% (2/2).">&nbsp;15</a></td>  <td class="src"><pre class="src">&nbsp;<a title="Line 92: Conditional coverage 100% (2/2).">        <span class="keyword">for</span> (Constructor&lt;?&gt; c : clazz.getConstructors()) {</a></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;93</td>  <td class="nbHitsCovered"><a title="Line 93: Conditional coverage 100% (2/2).">&nbsp;14</a></td>  <td class="src"><pre class="src">&nbsp;<a title="Line 93: Conditional coverage 100% (2/2).">            <span class="keyword">if</span> (areCompatible(c.getParameterTypes(), parameterTypes)) <span class="keyword">return</span> (Constructor&lt;T&gt;)c;</a></pre></td></tr>
<tr>  <td class="numLine">&nbsp;94</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;95</td>  <td class="nbHitsCovered">&nbsp;1</td>  <td class="src"><pre class="src">&nbsp;        <span class="keyword">return</span> <span class="keyword">null</span>;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;96</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;97</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;98</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;99</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;100</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Finds a method of the given class with the given name that matches the given arguments</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;101</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @param clazz The class containing the method should be found</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;102</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @param args The arguments that have to be assignable to the parameters of the method to be found</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;103</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @return The method of the given class with the given name that matches the given arguments</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;104</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;105</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">public</span> <span class="keyword">static</span> Method findMethod(Class&lt;?&gt; clazz, String methodName, Object... args) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;106</td>  <td class="nbHitsCovered">&nbsp;18</td>  <td class="src"><pre class="src">&nbsp;        <span class="keyword">return</span> findMethod(clazz, methodName, objectsToClasses(args));</pre></td></tr>
<tr>  <td class="numLine">&nbsp;107</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;108</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;109</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;110</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Finds a method of the given class with the given name having arguments of the given types</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;111</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @param clazz The class containing the method should be found</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;112</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @param parameterTypes The types of the parameters of the method to be found</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;113</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @return The method of the given class with the given name having arguments of the given types</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;114</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;115</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">public</span> <span class="keyword">static</span> Method findMethod(Class&lt;?&gt; clazz, String methodName, Class&lt;?&gt;... parameterTypes) {</pre></td></tr>
<tr>  <td class="numLine">&nbsp;116</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;117</td>  <td class="nbHitsCovered">&nbsp;18</td>  <td class="src"><pre class="src">&nbsp;            <span class="keyword">return</span> clazz.getMethod(methodName,  parameterTypes);</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;118</td>  <td class="nbHitsCovered">&nbsp;5</td>  <td class="src"><pre class="src">&nbsp;        } <span class="keyword">catch</span> (NoSuchMethodException e) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;119</td>  <td class="nbHitsCovered">&nbsp;5</td>  <td class="src"><pre class="src">&nbsp;            Method method = discoverMethod(clazz, methodName, parameterTypes);</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;120</td>  <td class="nbHitsCovered"><a title="Line 120: Conditional coverage 100% (2/2).">&nbsp;5</a></td>  <td class="src"><pre class="src">&nbsp;<a title="Line 120: Conditional coverage 100% (2/2).">            <span class="keyword">if</span> (method == <span class="keyword">null</span>) <span class="keyword">throw</span> <span class="keyword">new</span> IntrospectionException(e);</a></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;121</td>  <td class="nbHitsCovered">&nbsp;4</td>  <td class="src"><pre class="src">&nbsp;            <span class="keyword">return</span> method;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;122</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;123</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;124</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;125</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">static</span> Method discoverMethod(Class&lt;?&gt; clazz, String methodName, Class&lt;?&gt;... parameterTypes) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;126</td>  <td class="nbHitsCovered"><a title="Line 126: Conditional coverage 100% (2/2).">&nbsp;224</a></td>  <td class="src"><pre class="src">&nbsp;<a title="Line 126: Conditional coverage 100% (2/2).">        <span class="keyword">for</span> (Method m : clazz.getMethods()) {</a></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;127</td>  <td class="nbHitsUncovered"><a title="Line 127: Conditional coverage 75% (3/4) [each condition: 100%, 50%].">&nbsp;223</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 127: Conditional coverage 75% (3/4) [each condition: 100%, 50%].">            <span class="keyword">if</span> (m.getName().equals(methodName) &amp;&amp; areCompatible(m.getParameterTypes(), parameterTypes)) <span class="keyword">return</span> m;</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;128</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;129</td>  <td class="nbHitsCovered">&nbsp;1</td>  <td class="src"><pre class="src">&nbsp;        <span class="keyword">return</span> <span class="keyword">null</span>;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;130</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;131</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;132</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">boolean</span> areCompatible(Class&lt;?&gt;[] methodParams, Class&lt;?&gt;[] actualParam) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;133</td>  <td class="nbHitsUncovered"><a title="Line 133: Conditional coverage 75% (3/4) [each condition: 50%, 100%].">&nbsp;18</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 133: Conditional coverage 75% (3/4) [each condition: 50%, 100%].">        <span class="keyword">if</span> (methodParams == <span class="keyword">null</span> || methodParams.length != actualParam.length) <span class="keyword">return</span> <span class="keyword">false</span>;</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;134</td>  <td class="nbHitsCovered"><a title="Line 134: Conditional coverage 100% (2/2).">&nbsp;30</a></td>  <td class="src"><pre class="src">&nbsp;<a title="Line 134: Conditional coverage 100% (2/2).">        <span class="keyword">for</span> (<span class="keyword">int</span> i = 0; i &lt; methodParams.length; i++) {</a></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;135</td>  <td class="nbHitsCovered"><a title="Line 135: Conditional coverage 100% (2/2).">&nbsp;23</a></td>  <td class="src"><pre class="src">&nbsp;<a title="Line 135: Conditional coverage 100% (2/2).">            <span class="keyword">if</span> (!areCompatible(methodParams[i], actualParam[i])) <span class="keyword">return</span> <span class="keyword">false</span>;</a></pre></td></tr>
<tr>  <td class="numLine">&nbsp;136</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;137</td>  <td class="nbHitsCovered">&nbsp;7</td>  <td class="src"><pre class="src">&nbsp;        <span class="keyword">return</span> <span class="keyword">true</span>;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;138</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;139</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;140</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">boolean</span> areCompatible(Class&lt;?&gt; methodParam, Class&lt;?&gt; actualParam) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;141</td>  <td class="nbHitsUncovered"><a title="Line 141: Conditional coverage 75% (6/8) [each condition: 100%, 100%, 50%, 50%].">&nbsp;23</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 141: Conditional coverage 75% (6/8) [each condition: 100%, 100%, 50%, 50%].">        <span class="keyword">return</span> methodParam.isAssignableFrom(actualParam) ||</a></span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;142</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;                (methodParam.isPrimitive() ? areBoxingCompatible(methodParam, actualParam) : areBoxingCompatible(actualParam, methodParam));</pre></td></tr>
<tr>  <td class="numLine">&nbsp;143</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;144</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;145</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">boolean</span> areBoxingCompatible(Class&lt;?&gt; primitiveClass, Class&lt;?&gt; boxedClass) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;146</td>  <td class="nbHitsCovered">&nbsp;17</td>  <td class="src"><pre class="src">&nbsp;         <span class="keyword">return</span> boxedClass.getSimpleName().toLowerCase(Locale.getDefault()).startsWith(primitiveClass.getSimpleName());</pre></td></tr>
<tr>  <td class="numLine">&nbsp;147</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;148</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;149</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">private</span> <span class="keyword">static</span> Class&lt;?&gt;[] objectsToClasses(Object... args) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;150</td>  <td class="nbHitsUncovered"><a title="Line 150: Conditional coverage 50% (1/2).">&nbsp;22</a></td>  <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 150: Conditional coverage 50% (1/2).">        Class&lt;?&gt;[] parameterTypes = <span class="keyword">new</span> Class&lt;?&gt;[args == <span class="keyword">null</span> ? 0 : args.length];</a></span></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;151</td>  <td class="nbHitsCovered"><a title="Line 151: Conditional coverage 100% (2/2).">&nbsp;22</a></td>  <td class="src"><pre class="src">&nbsp;<a title="Line 151: Conditional coverage 100% (2/2).">        <span class="keyword">for</span> (<span class="keyword">int</span> i = 0; i &lt; parameterTypes.length; i++) { parameterTypes[i] = args[i].getClass(); }</a></pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;152</td>  <td class="nbHitsCovered">&nbsp;22</td>  <td class="src"><pre class="src">&nbsp;        <span class="keyword">return</span> parameterTypes;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;153</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;154</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr>  <td class="numLine">&nbsp;155</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="comment">/**</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;156</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * Returns a clone of the given original Object</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;157</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @param original The Object to be cloned</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;158</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @return A clone of the original object</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;159</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     * @throws CloneNotSupportedException if the original object is not cloneable</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;160</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;<span class="comment">     */</span></pre></td></tr>
<tr>  <td class="numLine">&nbsp;161</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    <span class="keyword">public</span> <span class="keyword">static</span> Object clone(Object original) <span class="keyword">throws</span> CloneNotSupportedException {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;162</td>  <td class="nbHitsCovered"><a title="Line 162: Conditional coverage 100% (2/2).">&nbsp;12</a></td>  <td class="src"><pre class="src">&nbsp;<a title="Line 162: Conditional coverage 100% (2/2).">        <span class="keyword">if</span> (!(original <span class="keyword">instanceof</span> Cloneable)) <span class="keyword">throw</span> <span class="keyword">new</span> CloneNotSupportedException();</a></pre></td></tr>
<tr>  <td class="numLine">&nbsp;163</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        <span class="keyword">try</span> {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;164</td>  <td class="nbHitsCovered">&nbsp;11</td>  <td class="src"><pre class="src">&nbsp;            <span class="keyword">return</span> original.getClass().getMethod(<span class="string">"clone"</span>).invoke(original);</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;165</td>  <td class="nbHitsCovered">&nbsp;2</td>  <td class="src"><pre class="src">&nbsp;        } <span class="keyword">catch</span> (Exception e) {</pre></td></tr>
<tr>  <td class="numLineCover">&nbsp;166</td>  <td class="nbHitsCovered">&nbsp;2</td>  <td class="src"><pre class="src">&nbsp;            <span class="keyword">throw</span> <span class="keyword">new</span> CloneNotSupportedException();</pre></td></tr>
<tr>  <td class="numLine">&nbsp;167</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;        }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;168</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;    }</pre></td></tr>
<tr>  <td class="numLine">&nbsp;169</td>  <td class="nbHits">&nbsp;</td>
  <td class="src"><pre class="src">&nbsp;}</pre></td></tr>
</table>

<div class="footer">Report generated by <a href="http://cobertura.sourceforge.net/" target="_top">Cobertura</a> 1.9.4.1 on 12/02/12 22.30.</div>
</body>
</html>
